package com.bdqn.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @Author 27435
 * @Date 2025/1/615:51
 * @Version 1.0
 */
@Configuration
@ComponentScan(basePackages = {"com.bdqn.*"})
@EnableWebMvc
public class SpringConfig {

    @Bean
    public CommonsMultipartResolver multipartResolver(){
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        multipartResolver.setDefaultEncoding("UTF-8");
        multipartResolver.setMaxUploadSize(1024*1024*10); // 单位是 字节
        return multipartResolver;
    }

    // 视图解析器
    @Bean
    public ViewResolver viewResolver(){
        InternalResourceViewResolver vr = new InternalResourceViewResolver();
        vr.setPrefix("/WEB-INF/page/");
        vr.setSuffix(".jsp");
        return vr;
    }

}
